package com.bosssoft.trainee.nontax.controller;

import com.bosssoft.trainee.nontax.common.Result;
import com.bosssoft.trainee.nontax.entity.po.Menu;
import com.bosssoft.trainee.nontax.entity.vo.MenuVO;
import com.bosssoft.trainee.nontax.service.MenuService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuqiang
 * @date 2022/6/18 23:14
 */

@Controller
public class MenuController {

    @Autowired
    MenuService menuService;

    @ResponseBody
    @GetMapping("/menu/list")
    public Result<Object> getMenu() {

        List<Menu> list = menuService.list();
        List<MenuVO> listVo = new ArrayList<>();
        for (Menu menu : list) {
            MenuVO menuVo = new MenuVO();
            BeanUtils.copyProperties(menu, menuVo);
            listVo.add(menuVo);
        }
        return Result.success(listVo);
    }
}
